<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="layout/tpl">
<head>
    <meta charset="UTF-8"/>
    <title>添加用户</title>
    <style>
        form {
            padding: 10px;
        }
    </style>
</head>
<body layout:fragment="content">
<form class="layui-form  layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label">用户账号</label>
        <div class="layui-input-block">
            <input type="text" id="username" name="username" lay-verify="username|required" autocomplete="off" placeholder="请输入用户账号" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">用户姓名</label>
        <div class="layui-input-block">
            <input type="text" id="name" name="name" autocomplete="off" placeholder="请输入用户姓名" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">店号</label>
        <div class="layui-input-block">
            <!--<input type="text" id="storeno" name="storeno" autocomplete="off" placeholder="请输入店号" class="layui-input">-->
            <select name="storeno" id="storeno" lay-search="">
                <option th:each="store:${stores}" th:value="${store.getAsString('storeno')}" th:text="${store.getAsString('storename')}"></option>
                <!--<option value="010">北京</option>-->
                <!--<option value="021" disabled>上海（禁用效果）</option>-->
                <!--<option value="0571" selected>杭州</option>-->
            </select>
        </div>
    </div>

    <div class="layui-form-item" pane="">
        <label class="layui-form-label">是否可用</label>
        <div class="layui-input-block">
            <input type="checkbox" id="available" checked="" name="open" lay-skin="switch" lay-filter="available" lay-text="ON|OFF">
        </div>
    </div>

    <div class="layui-form-item" pane="">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">

            <span th:each="role: ${roles}">
                <input type="checkbox" checked name="role" th:value="${role.getId()}" th:title="${role.getDescription()}">
            </span>
        </div>
    </div>
</form>
</body>
<script type="text/javascript" layout:fragment="myscript">
    var available = true;
    layui.use('form', function(){
        form = layui.form;
        form.on('switch(available)' , function(data){
            available = data.elem.checked;
        });
    });
</script>
</html>